home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
051-060
/
amok56
/
m2maker
/
txt
/
inputhandler.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
4KB
|
123 lines
(*---------------------------------------------------------------------------
:Program. m2Maker
:Author. Thomas Stolze
:Address. Goslarsche Str. 32, 3000 Hannover 21, Germany
:Phone. (0)511 / 75 10 77
:Version. V2.0
:Date. 13-Nov-90
:Copyright. Shareware
:Language. Modula-2
:Translator. M2Amiga V3.32d
:Contents. Programming Utility.
:Remark. Supports the M2Amiga System (C) by A+L AG Switzerland
---------------------------------------------------------------------------*)
IMPLEMENTATION MODULE InputHandler;
IMPORT ExecD;
IMPORT R;
FROM Arts IMPORT Assert;
FROM ExecD IMPORT Interrupt,IOStdReq,IOStdReqPtr,MsgPortPtr;
FROM ExecL IMPORT CloseDevice,DoIO,Forbid,
OpenDevice,Permit,PutMsg;
FROM ExecSupport IMPORT CreateExtIO,CreatePort,DeleteExtIO,DeletePort;
FROM Input IMPORT addHandler,inputName,remHandler;
FROM InputEvent IMPORT InputEvent,Class,InputEventPtr,Qualifiers,
QualifierSet;
FROM InitIntuition IMPORT InputMessage,prgPtr;
FROM IntuitionD IMPORT IDCMPFlags,IDCMPFlagSet,IntuiMessage,WindowPtr;
FROM IntuitionL IMPORT ActivateWindow;
FROM SYSTEM IMPORT ADDRESS,ADR,LONGSET;
VAR ioPort,
replyPort : MsgPortPtr;
intrpt : Interrupt;
inMsg : InputMessage;
ioReq : IOStdReqPtr;
(*$LoadA4:=TRUE*)
PROCEDURE Handler(eventptr{R.A0} : InputEventPtr): InputEventPtr;
BEGIN
IF rawkey = eventptr^.class THEN
IF (control IN eventptr^.qualifier) AND
(lShift IN eventptr^.qualifier) THEN
CASE eventptr^.code OF
40H,50H..59H:
WITH inMsg.event DO
code:=eventptr^.code;
class:=IDCMPFlagSet{rawKey};
qualifier:=eventptr^.qualifier;
iAddress:=NIL;
seconds:=eventptr^.timeStamp.secs;
micros:=eventptr^.timeStamp.micro;
idcmpWindow:=prgPtr^.window;
specialLink:=NIL;
END;
inMsg.news.node.type:=ExecD.message;
inMsg.news.length:=SIZE(IntuiMessage);
inMsg.news.replyPort:=replyPort;
ActivateWindow(prgPtr^.window);
PutMsg(prgPtr^.window^.userPort,ADR(inMsg));
eventptr:=eventptr^.nextEvent;
ELSE
END;
END;
END;
RETURN eventptr;
END Handler;
PROCEDURE InstallHandler;
BEGIN
intrpt.data:=NIL;
intrpt.code:=ADR(Handler);
intrpt.node.pri:=52;
ioReq^.data:=ADR(intrpt);
ioReq^.command:=addHandler;
ioReq^.length:=SIZE(InputEvent);
DoIO(ioReq);
Assert(ioReq^.error = 0,ADR("I/O Fehler"));
END InstallHandler;
PROCEDURE CauseInput(command : CARDINAL; len : LONGCARD; adr : ADDRESS);
BEGIN
ioReq^.command:=command;
ioReq^.length:=len;
ioReq^.data:=adr;
DoIO(ioReq);
Assert(ioReq^.error = 0,ADR("I/O Fehler"));
END CauseInput;
PROCEDURE Guard;
BEGIN
ioPort:=CreatePort(NIL,0);
Assert(ioPort # NIL,ADR("MsgPort not allocated"));
replyPort:=CreatePort(NIL,0);
Assert(replyPort # NIL,ADR("MsgPort not allocated"));
ioReq:=CreateExtIO(ioPort,SIZE(IOStdReq));
Assert(ioReq # NIL,ADR("IOStdReq not allocated"));
OpenDevice(ADR(inputName),0,ioReq,LONGSET{});
InstallHandler;
END Guard;
BEGIN
CLOSE
IF (intrpt.code # NIL) THEN
CauseInput(remHandler,0,ADR(intrpt)); CloseDevice(ioReq);
END;
IF (ioReq # NIL) THEN DeleteExtIO(ioReq); ioReq:=NIL; END;
IF (ioPort # NIL) THEN DeletePort(ioPort); ioPort:=NIL; END;
IF (replyPort # NIL) THEN DeletePort(replyPort); replyPort:=NIL; END;
END InputHandler.